import request from '@/request'

export function getArticles(data) {
  return request({
    url: '/blog/getBlogs',
    method: 'post',
    data: data
    // data: {
    //   currentPage: pageNo,
    //   userId: userId,
    //   pageSize: 8
    // }
  })
}
export function getLikeBlogs(data) {
    return request({
        url: '/blog/getLikeBlogs',
        method: 'post',
        data: data
    })
}

export function getHotArtices() {
  return request({
    url: '/blog/getHotBlogs',
    method: 'get'
  })
}

export function getNewArtices() {
  return request({
    url: '/blog/getNewBlogs',
    method: 'get'
  })
}

export function viewArticle(id) {
  return request({
    url: `/blog/getBlogById`,
    method: 'post',
    data: {
      id: id
    }
  })
}

export function getArticleById(id) {
  return request({
    url: `/blog/getBlogById`,
    method: 'post',
    data: {
      id: id
    }
  })
}

export function publishArticle(article) {
  return request({
    url: '/blog/editBlog',
    method: 'post',
    data: article
  })
}

export function listArchives() {
  return request({
    url: '/article/archives',
    method: 'get'
  })
}


/*
 * 以下俩接口暂时未用到
 * 可通过/article/list接口实现
 */
export function getArticlesByCategory(id) {
  return request({
    url: `/article/category/${id}`,
    method: 'get'
  })
}

export function getArticlesByTag(id) {
  return request({
    url: `/article/tag/${id}`,
    method: 'get'
  })
}
